package com.offcn.login;

import com.offcn.dao.StudentDao;
import com.offcn.entity.Page;
import com.offcn.entity.Student;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@MultipartConfig
@WebServlet("/student")
public class StuServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String curPage = req.getParameter("curPage");
        String name = req.getParameter("name");
        String sex = req.getParameter("sex");
        StudentDao sd = new StudentDao();
        int rows = sd.LikeNum(name,sex);
        Page p = new Page(rows,curPage);
        List<Student> list = sd.StuLike(name,sex,p);
        req.setAttribute("list",list);
        req.setAttribute("p",p);
        req.setAttribute("name",name);
        req.setAttribute("sex",sex);
        req.getRequestDispatcher("stuservlet.jsp").forward(req,resp);
    }
}
